class Coder {
    constructor(name) {
        this.name = name
    }
    work(prod) {
        console.log(`${this.name}应该实现${prod}`)
    }
}
class ProdManager {
    constructor() {
        this.workers = []
    }
    add(worker) {
        this.workers.push(worker)
    }
    // 通知工作
    notify() {
        for(let i = 0; i < this.workers.length; i++) {
            this.workers[i].work(i)
        }
    }
}
const front = new Coder('前端')
const back = new Coder('后端')
const ui = new Coder('ui')
const pm = new ProdManager()
pm.add(front)
pm.add(back)
pm.add(ui)
console.log(pm.workers);
pm.notify()
// 这二者没有中介，所以是观察者模式
// 发布者订阅者模式,需要一个中介